﻿using KseCms.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KseCms.Application
{
    public class Mapper : IRegister
    {
        public void Register(TypeAdapterConfig config)
        {
            config.ForType<Product, ProductDto>()
                .Map(dest => dest.CreatedTime, src => Convert.ToDateTime(src.CreatedTime.ToLongTimeString()))
                .Map(dest => dest.UpdatedTime, src => Convert.ToDateTime(src.UpdatedTime.ToLongTimeString()));

            config.ForType<ShoppingCart, ShoppingCartDto>()
              .Map(dest => dest.Product.Id, src => src.ProductId);

            config.ForType<Order, OrderDto>()
              .Map(dest => dest.Product.Id, src => src.ProductId)
              .Map(dest => (int)dest.Status, src => src.Status);

        }
    }
}
